var roleTreePanel;
Ext.define('treeNode', {
	extend : 'Ext.data.Model',
	fields : [{
				name : 'id',
				type : 'int'
			}, {
				name : 'text',
				type : 'string'
			}, {
				name : 'nodeUrl',
				type : 'string'
			}]
});
var root =({ 
    id:0,     
    expanded:false,
    text:'根节点',  
    attributes:[isDept=true,isKHZ=false,isCD=false],  
    }); 
var roleTreeStore = Ext.create('Ext.data.TreeStore',{
	model:treeNode,
	proxy:{
		type:'ajax',
		url:'queryRoleTreeList.do'
	},
	reader: {
    	type: 'json'
    },
    listeners: {
    	'expand': function(node){//展开事件
    	},
    	beforeload : function(ds, opration, opt) {//ajax往后台load数据之前的监听方法
			opration.params.id = opration.node.data.id;
			opration.params.name = opration.node.data.text;
			opration.params.parentId = opration.node.data.id;
		}
    },
    root:root
});
roleTreePanel= Ext.create('Ext.tree.Panel',{
	id:'ajaxRoleTree',
    width: 300,
    height: 450,
    title:'ajaxTree',
    xtype:'tree-reorder',
    store: roleTreeStore,
    rootVisible: true,
    split : true,
    autoScroll: true,
    listeners:{
    	itemclick:function(view, rec, el, index, e){//树的点击事件
			alert(rec.get('leaf'));
			if(rec.get('leaf')){//点击的是子节点的时候
				var pid = rec.get('id');
				var name = rec.get('text');
				var url = rec.get('nodeUrl');
				alert(url);
			}
	    }
    }
 });
roleTreePanel.store.load();
